﻿using EasyOAuth.Entity.Dto.Request;
using EasyOAuth.Entity.Dto.Result;
using EasyOAuth.Service;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MingHui.ShopExpress.Manage.API;

namespace EasyOAuth.Controllers
{
    /// <summary>
    /// 用户
    /// </summary>
    [Route("user")]
    public class UserController : OAuthController
    {
        UserService _service;

        IUserSession _session;

        /// <summary>
        /// 用户
        /// </summary>
        /// <param name="service"></param>
        public UserController(UserService service, IUserSession session)
        {
            _service = service;
            _session = session;
        }

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("login"), OAuthIgnore]
        public UserLoginResult Login(UserLoginRequest request)
        {
            return _service.Login(request);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [HttpGet("info")]
        public Dictionary<string, string> GetInfo() 
        {
            return _session.Get();
        }
    }
}
